<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/jsp/declare.jsp" %>

<!DOCTYPE html>
<html>
<head>
	<base href="<%=basePath %>" />
	<title>列表-小区</title>
	<%@ include file="/common/jsp/common.jsp" %>
	
	<script>
	function reloadFn(domId, json) {
		iSelectReload($("div[name='" + domId + "']"), json);
		$("div[name='" + domId + "']").find("li:first").click();
	}
	function findArea(city, level, domId) {
		doAjax({
			dataType:"text",
			url: "mvc/renter/findArea.htm",
			data: {city: city, level: level},
			success: function(json){
				reloadFn(domId, json);
			}
		});
	}
	function findStreet(area, domId) {
		doAjax({
			dataType:"text",
			url: "mvc/renter/findStreet.htm",
			data: {area: area},
			success: function(json){
				reloadFn(domId, json);
			}
		});
	}
	function findDept(street_id, domId) {
		doAjax({
			dataType:"text",
			url: "mvc/renter/findDept.htm",
			data: {street_id: street_id},
			success: function(json){
				reloadFn(domId, json);
			}
		});
	}
	function findCommunity(dept_id, domId) {
		doAjax({
			dataType:"text",
			url: "mvc/renter/findCommunity.htm",
			data: {dept_id: dept_id},
			success: function(json){
				reloadFn(domId, json);
			}
		});
	}
	</script>
</head>
<body id="community" class="bg-grey">
	<div class="center">
		<div class="picBar">
			<img src="aizu/images/community/communityListHead.jpg" />
		</div>
		<form action="" method="post">
			<div class="table">
				<div class="colx5">
					<div name="community_id" value="${community_id }" class="select middle" data='${communityListJson }' modal="false"
						option="{textField:'name',valueField:'id',onLoadClick:false}" defaultText="小区">
					</div>
				</div>
				<div class="colx5">
					<input type="text" name="keywords" value="${keywords }" class="input search middle" placeholder="请输入关键词" />
				</div>
			</div>
			<div class="table">
				<div class="colx2_5">
					<div name="city" value="${city }" class="select middle" data='${cityListJson }' modal="false"
						option="{textField:'area_name',valueField:'area_id',onLoadClick:false,onselect:function(select, op){
							findArea(op.value, 3, 'area');
						}}" defaultText="城市">
					</div>
				</div>
				<div class="colx2_5">
					<div name="area" value="${area }" class="select middle" data='${areaListJson }' modal="false"
						option="{textField:'area_name',valueField:'area_id',onLoadClick:false,onselect:function(select, op){
							findStreet(op.value, 'street_id');
						}}" defaultText="区县">
					</div>
				</div>
				<div class="colx2_5">
					<div name="street_id" value="${street_id }" class="select middle" data='${streetListJson }' modal="false"
						option="{textField:'name',valueField:'id',onLoadClick:false,onselect:function(select, op){
							findDept(op.value, 'dept_id');
						}}" defaultText="街道">
					</div>
				</div>
				<div class="colx2_5">
					<div name="dept_id" value="${dept_id }" class="select middle" data='${departmentListJson }' modal="false"
						option="{textField:'name',valueField:'id',onLoadClick:false,onselect:function(select, op){
							findCommunity(op.value, 'community_id');
						}}" defaultText="社区">
					</div>
				</div>
			</div>
			<ul class="center">
				<c:forEach var="community" items="${pagerModel.pageData }">
				<a href="mvc/renter/${community.id }/roomList.htm">
					<li class="item inline">
						<div class="communityPic"><img src="aizu/images/community/community.jpg" /></div>
						<div class="communityDesc">${community.dname }<br />${community.name }</div>
					</li>
				</a>
				</c:forEach>
			</ul>
			<%@ include file="/common/jsp/paging.jsp" %>
		</form>
	</div>
</body>
</html>